<?php

include_once('DbBroker.php');

function login($email,$password){
    $db = new DbBroker();
    $db->connect();
    
    $query = "
        SELECT usuarios.id FROM usuarios WHERE usuarios.email    = '$email'
                                           AND usuarios.password = '$password'
    ";
    
    $result = $db->query($query);
    
    if (is_array($result) && count($result) > 0)
        return (int)$result[0]['id'];
    else
        return 0; 
}

function register($email,$password){
    $db = new DbBroker();
    $db->connect();
    
    $query = "
        INSERT INTO usuarios(email, password)
        VALUES ('$email', '$password')
    ";

    return $db->insert($query);
}

//die(var_dump(login('vieraleonel1@gmail.com','123456')));